package tr.edu.metu.is.mega.server.entity;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedNativeQueries;
import javax.persistence.NamedNativeQuery;

/**
 * The persistent class for the reviewer database table.
 * 
 */
@NamedNativeQueries({ @NamedNativeQuery(name = "Reviewer.listSubmissions", 
    query = "SELECT * FROM REVIEWER R WHERE PKID NOT IN (SELECT R.PKID FROM REVIEWER R, ACTIVITY A, SUBMISSION S WHERE R.FK_ACTIVITYID=A.PKID AND S.FK_SUBMITTERTEAM=R.FK_TEAMID AND A.DUEDATE BETWEEN now()-interval '2 hour' and now()-interval '1 hour' )", resultClass = Reviewer.class) })
@Entity
public class Reviewer implements Serializable, tr.edu.metu.is.mega.server.core.BaseEntity {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer pkid;

    // bi-directional many-to-one association to Activity
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "fk_activityid")
    private Activity activity;

    // bi-directional many-to-one association to Team
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "fk_reviewerteamid")
    private Team reviewerTeam;

    // bi-directional many-to-one association to Team
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "fk_teamid")
    private Team team;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "fk_reviewactivityid")
    private Activity reviewActivity;

    /**
     * Default constructor.
     */
    public Reviewer() {
    }

    /**
     * Returns pkid.
     * 
     * @return the pkid
     */
    @Override
    public Integer getPkid() {
        return pkid;
    }

    /**
     * Sets pkid value.
     * 
     * @param pkid the pkid to set
     */
    @Override
    public void setPkid(Integer pkid) {
        this.pkid = pkid;
    }

    /**
     * Returns activity.
     * 
     * @return the activity
     */
    public Activity getActivity() {
        return activity;
    }

    /**
     * Sets activity value.
     * 
     * @param activity the activity to set
     */
    public void setActivity(Activity activity) {
        this.activity = activity;
    }

    /**
     * Returns reviewerTeam.
     * 
     * @return the reviewerTeam
     */
    public Team getReviewerTeam() {
        return reviewerTeam;
    }

    /**
     * Sets reviewerTeam value.
     * 
     * @param reviewerTeam the reviewerTeam to set
     */
    public void setReviewerTeam(Team reviewerTeam) {
        this.reviewerTeam = reviewerTeam;
    }

    /**
     * Returns team.
     * 
     * @return the team
     */
    public Team getTeam() {
        return team;
    }

    /**
     * Sets team value.
     * 
     * @param team the team to set
     */
    public void setTeam(Team team) {
        this.team = team;
    }

    /**
     * Returns reviewActivity.
     * 
     * @return the reviewActivity
     */
    public Activity getReviewActivity() {
        return reviewActivity;
    }

    /**
     * Sets reviewActivity value.
     * 
     * @param reviewActivity the reviewActivity to set
     */
    public void setReviewActivity(Activity reviewActivity) {
        this.reviewActivity = reviewActivity;
    }

}
